<!DOCTYPE html>
<html  xmlns:th="http://www.thymeleaf.org"  lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<title>APP开发|软件开发|网站建设|微信小程序开发</title>

	<!-- 网站icon图标 -->
	<link rel="icon" href="favicon.ico" type="image/x-icon">
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">

	<!-- Bootstrap -->
	<link href="css/bootstrap.min.css" rel="stylesheet">

	<!-- load global css -->
	<link  href="css/global.css" rel="stylesheet">
        
    <!--图片滑杆样式-->
    <link href="http://www.17sucai.com/preview/1191101/2018-05-17/jigsaw/css/jigsaw.css" rel="stylesheet">

	<style type="text/css">
		/** 按钮 */
		.btn-primary {
			color: #fff;
			background-color: #ED5001;
			border-color: #F4A501;
			border-radius: 25px;
			-moz-border-radius: 25px;
			-webkit-border-radius: 25px;
			height: 55px;
			font-weight: 500;
		}

		/** 发送验证码 */
		.btn-send {
			color: #fff;
			font-size: 13px;
			background-color: #ED5001;
			border-color: #F4A501;
			border-radius: 25px;
			-moz-border-radius: 25px;
			-webkit-border-radius: 25px;
			height: 35px;
		}

		/** 输入框 */
		.input {
			background: #F4A501;
			border-color: #F4A501;
			border-radius: 25px;
			-moz-border-radius: 25px;
			-webkit-border-radius: 25px;
			border: 1px solid #F4A501;
			color: white;
			height: 55px;
		}

		/** 提示文字 */
		input::input-placeholder {
			color: #fff !important;
		}

		input::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
			color: #fff !important;
		}

		input:-moz-placeholder, textarea:-moz-placeholder {
			color: #fff !important;
		}

		input::-moz-placeholder, textarea::-moz-placeholder {
			color: #fff !important;
		}

		input:-ms-input-placeholder, textarea:-ms-input-placeholder {
			color: #fff !important;
		}
    
        .refreshIcon {
            left: 275px;
        }
	</style>
</head>

<body>
	<div class="panel-default" style="width: 100%;overflow: hidden;">
		<div class="ax_default image" style="margin-bottom: -15px;z-index: 1;">
			<img class="img" src="images/page_bg.jpg" style="width: 100%;" />
		</div>

        <div class="panel-body" style="align-content: center;position: absolute;left: 10%; width: 90%;top: 70%;z-index: 2;">
            <div class="row">
                <div class="col-xs-10" align="center">
                    <input name="tel" id="tel" type="tel" class="form-control input" maxlength="11" placeholder="请输入您的手机号码" />
                </div>
            </div>
            <br />
            
            <div class="row" id="divSendCode" style="display: none;">
                <div class="col-xs-10" align="center">
                    <input name="code" id="code" type="number" class="form-control input" maxlength="6" placeholder="请输入验证码" />
                    
                    <!--获取验证码-->
                    <div style="position: absolute;right: 25px;top: 11px;">
                        <button type="button" id="btnGetCode" onclick="javascript:getCode();" class="btn btn-send">获取验证码</button>
                    </div>
                </div>
            </div>
            <div class="row" id="divImgCode">
                <div id="captcha" style="position: relative"></div>
            </div>
            <br />
            
            <div class="row" id="iosDownload">
                <div class="col-xs-10" align="center">
                    <button type="button" onclick="javascript:openOrDownLoadApp();" class="btn btn-primary btn-lg btn-block">马上贷款</button>
                </div>
            </div>
        </div>

		<!-- 阴影遮罩 -->
		<div id="bgDiv" onload="resetHeight(this);" class="ax_default image" style="position: absolute;left: 0;top: 0;z-index: 9998;width: 100%;height:100%;background-color: rgba(127, 127, 127, 0.85);">
		</div>

		<!-- 提示文字 -->
		<div id="bgDiv_title" class="ax_default image" style="position: absolute;right: 0;top: 0;z-index: 9999;width: 100%;height:180px;background: url('images/up_font.png') no-repeat right;">
		</div>
	</div>

	<!-- [S]模态框 -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel">手机号码不为空！</h4>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel">手机号码格式有误！</h4>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel">操作失败,请稍后再试！</h4>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<!--通用提示-->
	<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel4"></h4>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>
	<!-- [E]模态框 -->

	<!-- 隐藏文本域 -->
	<input id="androidUrl" type="hidden" value="" />
	<input id="iosUrl" type="hidden" value="" />
	<input id="theUrl" type="hidden" value="" />

	<script src="js/jquery.min.js" type="text/javascript" language="JavaScript"></script>
	<script src="js/bootstrap.min.js" type="text/javascript" language="JavaScript"></script>
    
    <!-- jQuery 滑杆验证码 -->
    <script src="js/jigsaw.js" type="text/javascript" language="JavaScript"></script>

	<script type="text/javascript">

		// 获取终端的相关信息
		var Terminal = {
			// 辨别移动终端类型
			platform: function () {
				var u = navigator.userAgent, app = navigator.appVersion;
				return {
					// android终端或者uc浏览器
					android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
					// 是否为iPhone或者QQHD浏览器
					iPhone: u.indexOf('iPhone') > -1,
					// 是否iPad
					iPad: u.indexOf('iPad') > -1
				};
			}(),
			// 辨别移动终端的语言：zh-cn、en-us、ko-kr、ja-jp...
			language: (navigator.browserLanguage || navigator.language).toLowerCase()
		}

		// 根据不同的终端，跳转到不同的地址
		var iosUrl = document.getElementById('iosUrl').value;
		var androidUrl = document.getElementById('androidUrl').value;
		var theUrl = document.getElementById('theUrl').value;

		if (Terminal.platform.android) {
			theUrl = androidUrl;

			//隐藏IOS下载按钮
			//$('#iosDownload').hide();
			//$('#androidDownload').show();
		}
		else if (Terminal.platform.iPhone) {
			theUrl = iosUrl;

			//隐藏安卓下载按钮
			//$('#iosDownload').show();
			//$('#androidDownload').hide();
		}
		else if (Terminal.platform.iPad) {
			// 还可以通过language，区分开多国语言版
			switch (Terminal.language) {
				case 'en-us':
					theUrl = iosUrl;
					break;
				case 'ko-kr':
					theUrl = iosUrl;
					break;
				case 'ja-jp':
					theUrl = iosUrl;
					break;
				default:
					theUrl = iosUrl;
			}
		}


		//////////////////////////////////////////////////////////////
		window.onload = function () {
			setHeight();

			//遮罩层
			var bgDiv = document.getElementById('bgDiv');
			var titleInfo = document.getElementById('bgDiv_title');
			if (!isWeiXin()) {
				bgDiv.style.display = 'none';
				titleInfo.style.display = 'none';
			}
			else {
				bgDiv.style.display = 'block';
				titleInfo.style.display = 'block';
			}

			//默认加载
			openOrDownLoadApp(3);
		};

		document.body.onresize = function () {
			setHeight();
		}


		//////////////////////////////////////////////////////////////
		//设置遮罩层的高度
		function setHeight() {
			var _h = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
			//重置层的高度
			document.getElementById("bgDiv").style.height = _h + 'px';
		}

		//判断是否为微信
		function isWeiXin() {
			var ua = window.navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				return true;
			} else {
				return false;
			}
		}

		//跳转
		function gotoDownload(type) {
			switch (type) {
				case 1://IOS
					window.location.href = iosUrl;
					break;
				case 2://Android
					window.location.href = androidUrl;
					break;
				default:
					/***打开app的协议***/
					window.location.href = theUrl;
					break;
			}
		}

		function successCallback(responseData) {
			console.log(responseData);
		}

		//////////////////////////////////////////////////////////////
		//打开或下载App
		//type 1 IOS 2 Android
		function openOrDownLoadApp(type) {

			if (isWeiXin()) {
				return;
			}

			//手机号
			var strTel = $("#tel").val();
			if (strTel.length <= 0) {
				if (type != 3) {
					$("#myModal").modal('show');
				}
				return;
			}
			else if (!(/^1[34578]\d{9}$/.test(strTel))) {
				if (type != 3) {
					$("#myModal2").modal('show');
				}
				return;
			}

			//验证码
			var strCode = $("#code").val();
			if (strCode.length <= 0) {
				if (type != 3) {
					$('#myModalLabel4').html('验证码不为空！');
					$("#myModal4").modal('show');
				}
				return;
			}
			else if (!(/^[0-9]{4,6}$/.test(strCode))) {
				if (type != 3) {
					$('#myModalLabel4').html('验证码格式有误！');
					$("#myModal4").modal('show');
				}
				return;
			}

			//验证码验证,通过验证提交
			checkCode(strTel, strCode, function () {
				//渠道编号
				var agentId = getQueryString("agentId");
				var strUrl = "http://xxxx/xxxx?agentId=" + agentId + "&loginMobile=" +
				 + strTel + "&downLoadUrl=" + theUrl;

				window.location.replace(strUrl);
			});
		}
	</script>

	<script type="text/javascript" language="javascript">
		var request_host = window.location.protocol + '//' + window.location.host + '/api/';

		/** 判断是否为微信 */
		function isWeiXin() {
			var ua = window.navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == 'micromessenger') {
				return true;
			} else {
				return false;
			}
		}

		/** 判断是否为PC端浏览器 */
		function isPCBrowser() {
			var userAgentInfo = navigator.userAgent;
			var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");

			for (var v = 0; v < Agents.length; v++) {
				if (userAgentInfo.indexOf(Agents[v]) > 0)
					return false;
			}

			return true;
		}

		/** 获取浏览器参数 */
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null) return unescape(r[2]); return '';
		}

		/** 获取验证码 */
		function getCode() {
			//手机号
			var strTel = $("#tel").val();
			if (strTel.length <= 0) {
				$("#myModal").modal('show');
				return;
			}
			else if (!(/^1[34578]\d{9}$/.test(strTel))) {
				$("#myModal2").modal('show');
				return;
			}

			$.ajax({
				url: request_host + 'sendCode',
				type: 'POST',
				dataType: "JSON",
                contentType: "application/json",
                data: JSON.stringify({
                    'phone': strTel,
                    'codeType': '下载'
                }),
				xhrFields: {
					withCredentials: true //设置运行跨域操作
				},
				success: function (responseData) {
					console.log('请求成功,详见！:' + responseData);

					var code = Number.parseInt(responseData.code);
					var msg = responseData.msg;
					if (code == 1) {
						//成功倒计时
						startCountDown();
					}

					$('#myModalLabel4').html(msg);
					$("#myModal4").modal('show');
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					// 状态码 200 成功
					var code = XMLHttpRequest.status;
					console.log(code);

					// 状态
					var rCode = XMLHttpRequest.readyState;
					console.log(rCode);

					// 错误信息
					var responseData = JSON.stringify(XMLHttpRequest.responseData);
					console.log(textStatus);
					console.log(responseData);
					console.log(XMLHttpRequest.statusText);

					$("#myModal3").modal('show');
				}
			});
		}

		/** 倒计时 */
		function startCountDown() {
			var $btn = $("#btnGetCode");
			var total_time = 60;//倒计时60秒

			$btn.attr('disabled',true); //禁用

			setTime = setInterval(function () {
				if (total_time <= 1) {
					clearInterval(setTime);

					$btn.text('重新获取');
					$btn.attr('disabled',false); //启用
					return;
				}
				total_time--;

				$btn.text(total_time + '秒');
			}, 1000);
		}

		/**验证手机号 */
		function checkCode(strPhone, strCode,successBack) {
			$.ajax({
				url: request_host + 'verifyCode',
				type: 'POST',
				dataType: "JSON",
                contentType: "application/json",
                data: JSON.stringify({
                    'phone': strPhone,
                    'code': strCode
                }),
				xhrFields: {
					withCredentials: true //设置运行跨域操作
				},
				success: function (responseData) {
					console.log('请求成功,详见！:' + responseData);

					var code = Number.parseInt(responseData.code);
					var msg = responseData.msg;
					if (code == 1) {
						//成功
						successBack();
					}

					$('#myModalLabel4').html(msg);
					$("#myModal4").modal('show');
				},
				error: function (XMLHttpRequest, textStatus, errorThrown) {
					// 状态码 200 成功
					var code = XMLHttpRequest.status;
					console.log(code);

					// 状态
					var rCode = XMLHttpRequest.readyState;
					console.log(rCode);

					// 错误信息
					var responseData = JSON.stringify(XMLHttpRequest.responseData);
					console.log(textStatus);
					console.log(responseData);
					console.log(XMLHttpRequest.statusText);

					$("#myModal3").modal('show');
				}
			});
		}
	</script>
    
    <script type="text/javascript">
         //图片滑杆验证码
         jigsaw.init(document.getElementById('captcha'), function () {
                    $('#divSendCode').fadeIn();
                    $('#divImgCode').fadeOut();
                    console.log('图片滑杆验证码，验证通过');
        });
                            
        function touches(obj,direction,fun){
            
            //obj:ID对象
            //direction:swipeleft,swiperight,swipetop,swipedown,singleTap,touchstart,touchmove,touchend
            //          划左，    划右，     划上，   划下，    点击，    开始触摸， 触摸移动， 触摸结束
            
            //fun:回调函数
            var defaults = {x: 5,y: 5,ox:0,oy:0,nx:0,ny:0};
            
            direction=direction.toLowerCase();
            
            //配置：划的范围在5X5像素内当点击处理
            obj.addEventListener("touchstart",function() {
                                 
                                 defaults.ox = event.targetTouches[0].pageX;
                                 defaults.oy = event.targetTouches[0].pageY;
                                 defaults.nx = defaults.ox;
                                 defaults.ny = defaults.oy;
                                 if(direction.indexOf("touchstart")!=-1)fun();
                                 }, false);
                                 
                                 obj.addEventListener("touchmove",function() {
                                                      event.preventDefault();
                                                      defaults.nx = event.targetTouches[0].pageX;
                                                      defaults.ny = event.targetTouches[0].pageY;
                                                      if(direction.indexOf("touchmove")!=-1)fun();
                                                      }, false);
                                                      
                                                      obj.addEventListener("touchend",function() {
                                                                           
                                                               var changeY = defaults.oy - defaults.ny;
                                                               var changeX = defaults.ox - defaults.nx;
                                                               if(Math.abs(changeX)>Math.abs(changeY)&&Math.abs(changeY)>defaults.y){
                                                               
                                                               //左右事件
                                                               if(changeX > 0) {
                                                               if(direction.indexOf("swipeleft")!=-1)fun();
                                                               }else{
                                                               if(direction.indexOf("swiperight")!=-1)fun();
                                                               }
                                                               }
                                                               else if(Math.abs(changeY)>Math.abs(changeX)&&Math.abs(changeX)>defaults.x){
                                                               
                                                               //上下事件
                                                               if(changeY > 0) {
                                                               if(direction.indexOf("swipetop")!=-1)fun();
                                                               }else{
                                                               if(direction.indexOf("swipedown")!=-1)fun();
                                                               }
                                                               }else{
                                                               //点击事件
                                                               if(direction.indexOf("singleTap")!=-1)fun();
                                                               }
                                                               
                                                               if(direction.indexOf("touchend")!=-1)fun();
                                                               }, false);
        }
    </script>
</body>

</html>
